package com.zhf.xml05;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @Author: ZhaoHuanfeng
 * @Date: 2020/9/26 16:33
 */
public class TestJDBC {

    //查询所有员工信息
    public static void main(String[] args) throws SQLException {

        //获取连接
        Connection connection = JDBCUtils.getConnection();

        //获取语句执行对象
        Statement statement = connection.createStatement();

        //执行SQL语句
        ResultSet resultSet = statement.executeQuery("select * from employee");

        //处理结果集
        while(resultSet.next()){

            String name = resultSet.getString("ename");
            System.out.println("员工的姓名: " + name);
        }

        //释放资源
        resultSet.close();
        statement.close();
        connection.close();


    }
}
